package com.iyunwen.datatool.model.dbdo;

import com.iyunwen.datatool.model.vo.BaseNormalizationDataVO;
import com.iyunwen.datatool.utils.MD5Utils;
import lombok.Data;


/**
 * @description: 事件日志
 * @author: Zhu.Guodong
 * @create: 2020-03-16 20:00
 * @version:
 */
@Data
public class EventDataDO extends BaseNormalizationDataVO {

    /**
     * 主键
     */
    private Long id;

    /**
     * 标记
     */
    private String eventRemark;

    /**
     * 事件时标
     */
//    private Timestamp eventTime;
    private long eventTime;

    /**
     * 类型
     */
    private String eventType;

    /**
     * 主/从
     */
    private String masterOrSlave;

    /**
     * 事件号
     */
    private String eventNumber;

    /**
     * 事件来源
     */
    private String eventSource;

    /**
     * 事件描述
     */
    private String eventDesc;

    /**
     * 事件等级
     */
    private String eventLevel;

    /**
     * 状态
     */
    private String eventStatus;

    /**
     * 持续时间
     */
    private String duration;

    /**
     * 设备描述
     */
    private String deviceDescription;

    /**
     * 操作者
     */
    private String operator;

    /**
     * 确认人
     */
    private String conformPerson;

    /**
     * 表格背景色
     */
    private String backgroundColor;


    public String getDataUniqSFlag() {
        StringBuilder sb = new StringBuilder();
        sb.append(eventType)
                //.append(masterOrSlave)
                //.append(eventNumber)
                .append(eventSource)
                .append(eventDesc)
                .append(eventLevel)
                .append(eventStatus);
        return MD5Utils.MD5(sb.toString(), 32);
    }

    public EventDataDO getNewUniqBaseData() {
        EventDataDO eventDataTemp = new EventDataDO();
        eventDataTemp.setEventType(this.eventType);
        //eventDataTemp.setMasterOrSlave(this.masterOrSlave.replaceAll("[0-9a-zA-Z_\\s]+","*"));
        //eventDataTemp.setEventNumber(eventNumber);
        eventDataTemp.setEventSource(eventSource.replaceAll("[0-9a-zA-Z\\s]+", "*"));
        eventDataTemp.setEventDesc(
                eventDesc
                        .replaceAll("(?<=[第])[一二三四五六七八九十]+", "*")
                        //罗马数字一到十
                        .replaceAll("(IX|IV|V|V?I{1,3})(?=段)", "*")
                        .replaceAll("[0-9*]+", "*"));
        eventDataTemp.setEventLevel(eventLevel);
        eventDataTemp.setEventStatus(eventStatus);

        return eventDataTemp;
    }

}
